import os
import sys
import re
from matplotlib import pyplot as plt



class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'


fps = re.compile('ReceiveCount:(\d+)')


fn = sys.argv[1]

lines = open(fn).readlines()
fpss = []

num = 1
total = 1
xv = []
zv = []
for l in lines:
    ret = fps.findall(l)
    if len(ret) > 0:
        '''
        ff = float(ret[0])
        n = (int)(ff-1)
        n2 = min(max(0, n), 29)
        nums[n2] += 1
        if ff < 20:
        	num += 1
        	print bcolors.FAIL+ret[0]+bcolors.ENDC
        else:
        	print ret[0]
        total += 1
        #fpss.append(ret[0])
        '''
        #print ret[0][0]
        xv.append(int(ret[0]))
        #zv.append(float(ret[0][2]))

minVal = min(xv)
maxVal = max(xv)
cut = 100
collectNum = (maxVal+99)/100
collectResult = [0]*collectNum
for v in xv:
    r = v/100
    collectResult[r] += 1

totalNum = len(xv)

for c in collectResult:
    print c*100.0/totalNum

#for x in xv:
#    print x

print num*1.0/total
plt.plot(xv, "ro")
plt.show()

